import statements_import from './import.js'
import statements_call from './call.js'
import statements_function from './function.js'
import statements_variable from './variable.js'
import statements_set from './set.js'
import statements_if from './if.js'
import statements_return from './return.js'
import statements_while from './while.js'
import statements_for from './for.js'

const statements = [
  statements_import,
  statements_call,
  statements_function,
  statements_variable,
  statements_set,
  statements_if,
  statements_return,
  statements_while,
  statements_for
]

const statement = (tokens) => {
  for (const statement of statements) {
    if (statement.is(tokens)) {
      return statement.parse(tokens)
    }
  }
  tokens.croak(`Can't handle token: ${ tokens.peek().value }`)
}

export default statement